public class Student {

    private String name;
    private String gender;
    private int age;
    private String id;


    //不带参数的默认构造函数
    public Student(){
        this.name = "未知姓名";
        this.gender = "未知性别";
        this.age = 0;
        this.id = "未知学号";
    }

    //带参数的构造函数(初始化所有属性)
    public Student( String name, String gender, int age, String id) {
        this.name = name;
        this.gender = gender;
        this.age = age;
        this.id = id;
    }

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }

    public String getGender() {
        return gender;
    }

    public void setGender(String gender) {
        this.gender = gender;
    }

    public int getAge() {
        return age;
    }

    public void setAge(int age) {
        if (age > 0){
        this.age = age;
        } else {
            System.out.println("You had inputted wrong age!");
        }
    }

    public String getId() {
        return id;
    }

    public void setId(String id) {
        this.id = id;
    }

    public void showinfo() {
        System.out.println("姓名：" + name + "\n性别：" + gender + "\n年龄：" + age + "\n学号：" + id);
        System.out.println("-------------------");
    }
}
